#coding=utf-8
import matplotlib
import matplotlib.pyplot as pyplot
import matplotlib.font_manager as font_manager
import numpy as numpy

x = numpy.linspace(22, 50, 28)
y = 1000 * x + 1
z = x**3
# pyplot.figure()
# pyplot.plot(x, z)
pyplot.figure(num=3, figsize=(8, 5))

l1, = pyplot.plot(x, y, label='财富')
l2, = pyplot.plot(x, z, color='red', label='年龄', linewidth=2, linestyle='--')
pyplot.xlim((22,50))
pyplot.ylim((0,100000))
pyplot.xlabel('年龄')
# pyplot.ylabel('rich')

new_ticks = numpy.linspace(22, 50, 5)
pyplot.xticks(new_ticks)
pyplot.yticks([10000, 30000, 50000, 100000], ['贫穷', '小康', '富裕', '奢侈'])
pyplot.ylabel('财富')



ax = pyplot.gca()
ax.spines['right'].set_color('none')
ax.spines['top'].set_color('none')
ax.xaxis.set_ticks_position('bottom')
ax.yaxis.set_ticks_position('left')
ax.spines['bottom'].set_position(('data', 30000))
ax.spines['left'].set_position(('data', 32))

pyplot.legend(handles=[l1, l2], labels=['财富', '年龄'], loc='best')


x0 = 36
z0 = x0**3
pyplot.scatter(x0, z0, s=50, color='b')
pyplot.plot([x0,x0], [z0, 30000],'k--', lw=2.5)
pyplot.annotate(r'$2x+1=%s$' % z0, xy=(x0, z0), xytext=(+30, -30), textcoords='offset points', arrowprops=dict(arrowstyle='->', connectionstyle='arc3, rad=.2'))

pyplot.show()